package com.eleadmin.common.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.eleadmin.common.system.mapper.MedicalImagingMapper;
import com.eleadmin.common.system.service.MedicalImagingService;
import com.eleadmin.common.system.entity.MedicalImaging;
import com.eleadmin.common.system.param.MedicalImagingParam;
import com.eleadmin.common.core.web.PageParam;
import com.eleadmin.common.core.web.PageResult;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 医学图像信息表Service实现
 *
 * @author EleAdmin
 * @since 2025-03-16 22:21:54
 */
@Service
public class MedicalImagingServiceImpl extends ServiceImpl<MedicalImagingMapper, MedicalImaging> implements MedicalImagingService {

    @Override
    public PageResult<MedicalImaging> pageRel(MedicalImagingParam param) {
        PageParam<MedicalImaging, MedicalImagingParam> page = new PageParam<>(param);
        //page.setDefaultOrder("create_time desc");
        List<MedicalImaging> list = baseMapper.selectPageRel(page, param);
        return new PageResult<>(list, page.getTotal());
    }

    @Override
    public List<MedicalImaging> listRel(MedicalImagingParam param) {
        List<MedicalImaging> list = baseMapper.selectListRel(param);
        // 排序
        PageParam<MedicalImaging, MedicalImagingParam> page = new PageParam<>();
        //page.setDefaultOrder("create_time desc");
        return page.sortRecords(list);
    }

    @Override
    public MedicalImaging getByIdRel(Integer id) {
        MedicalImagingParam param = new MedicalImagingParam();
        param.setId(id);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
